local skel= fk.CreateSkill({
    name = "history__falu",
  })
  
  Fk:loadTranslationTable{
    ["history__falu"] = "法箓",
    [":history__falu"] = "当你成为牌的目标后或你的牌因弃置进入弃牌堆时，若此牌花色没有记录，则记录之。游戏开始时，你获得四种花色的记录",
    ["@history__falu"] = "法箓",
  }

  skel:addEffect(fk.GameStart, { 
    can_trigger = function(self, event, target, player, data)
      return player:hasSkill(skel.name)
    end,
    on_cost = function(self, event, target, player, data)
      return true
    end,
    on_use = function (self, event, target, player, data)
      local room = player.room
      local suits={"log_spade","log_heart","log_club","log_diamond"}
      --local suits={"log_heart"}
      room:setPlayerMark(player, "@history__falu", suits)
    end,
  })



local recordSuitCanRefresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and data.card.suit ~= Card.NoSuit
end
  
local recordSuitOnRefresh = function(self, event, target, player, data)
    local suit = data.card:getSuitString(true)
    local record = player:getTableMark("@history__falu")
    if table.insertIfNeed(record, suit) then
      player.room:setPlayerMark(player, "@history__falu", record)
    end
end
  
skel:addEffect(fk.TargetConfirmed, {
    can_refresh = recordSuitCanRefresh,
    on_refresh = recordSuitOnRefresh,
  })

skel:addEffect(fk.AfterCardsMove, {
    can_refresh= function(self, event, target, player, data)
        if player:hasSkill(skel.name) then
          local ids = {}
          for _, move in ipairs(data) do
            if move.from and move.from == player and move.toArea == Card.DiscardPile and move.moveReason == fk.ReasonDiscard then
              for _, info in ipairs(move.moveInfo) do
                if (info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip)then
                  table.insertIfNeed(ids, info.cardId)
                end
              end
            end
          end
          ids = table.filter(ids, function (id)
            return table.contains(player.room.discard_pile, id)
          end)
          ids = player.room.logic:moveCardsHoldingAreaCheck(ids)
          if #ids > 0 then
            event:setCostData(self, {cards = ids})
            return true
          end
        end
    end,
    on_refresh = function(self, event, target, player, data)
        local ids = event:getCostData(self).cards
        for _,id in ipairs(ids) do
            local card=Fk:getCardById(id)
            local suit = card:getSuitString(true)
            local record = player:getTableMark("@history__falu")
            if table.insertIfNeed(record, suit) then
                player.room:setPlayerMark(player, "@history__falu", record)
            end
        end
    end
})

  
  return skel